﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace MeetingFinder
{
    public class MeetingItem
    {
        public enum Status { Confirmed, Updated, New, Pending, Completed, Notification, History };

        public MeetingItem() { }

        public MeetingItem(string Name, 
                                DateTime DateTime, 
                                string Location,
                                string Description,
                                Status Status)
        {
            _meetingName = Name;
            _meetingDateTime = DateTime;
            _meetingLocation = Location;
            _meetingDescription = Description;
            _meetingStatus = Status;
        }

        public string _meetingName { get; set; }

        public DateTime _meetingDateTime { get; set; }

        public string _meetingLocation { get; set; }

        public string _meetingDescription { get; set; }

        public string _meetingItemID { get; set; }

        public string _meetingCreatorID { get; set; }

        public string _groupID { get; set; }

        public string _groupName { get; set; }

        public string _notificationID { get; set; }

        public Status _meetingStatus { get; set; }

        public string _newMeetingStatus { get; set; }

        public GroupMember _meetingOwner { get; set; }

        public GroupMember _meetingGroupMembers { get; set; }

        public void convertToMeetingItem(ServerMeetingItem serverItem, Status meetingStatus)
        {
            //copy info from serverMeetingItem list to meetingItemList and add meeting status to each
            this._meetingName = serverItem.title;
            if (serverItem.f_time == "0000-00-00 00:00:00")
            {
                this._meetingDateTime = Convert.ToDateTime("1111-11-11 11:11:11");
            }else
                this._meetingDateTime = Convert.ToDateTime(serverItem.f_time);
            this._meetingLocation = serverItem.f_location;
            this._meetingDescription = serverItem.content;
            this._meetingStatus = meetingStatus;
            this._meetingItemID = serverItem.id;
            this._meetingCreatorID = serverItem.creator_id;
            this._groupID = serverItem.group_id;

            setGroupName(serverItem.group_id);
        }

        public void convertServerNotificationToMeetingItem(ServerNotificationItem serverItem)
        {

            //this._meetingName = "need to find meeting item and set";
            //this._meetingLocation = "need to find meeting item and set";
            //this._meetingDescription = serverItem.content;
            //this._meetingStatus = Status.Notification;
            //this._meetingItemID = serverItem.meeting_id;
            //this._notificationID = serverItem.id;
            //this._meetingCreatorID = "need to find meeting item and set";
            //this._groupID = "need to find meeting item and set";
        }

        public static void copyMeetingItem(MeetingItem original, MeetingItem copy)
        {
            copy._groupID = original._groupID;
            copy._meetingCreatorID = original._meetingCreatorID;
            copy._meetingDateTime = original._meetingDateTime;
            copy._meetingDescription = original._meetingDescription;
            copy._meetingGroupMembers = original._meetingGroupMembers;
            copy._meetingItemID = original._meetingItemID;
            copy._meetingLocation = original._meetingLocation;
            copy._meetingName = original._meetingName;
            copy._meetingOwner = original._meetingOwner;
            copy._meetingStatus = original._meetingStatus;
            copy._newMeetingStatus = original._newMeetingStatus;
            copy._notificationID = original._notificationID;
        }

        private void setGroupName(string groupID)
        {
            var currentApp = App.Current as App;

            foreach (ProjectGroup group in currentApp._projectGroupList)
                if (groupID == group._groupID)
                    this._groupName = group._moduleCode;
        }

    }
}
